//Wrapper for EE::MeshBase
#pragma once
#include "stdafx.h"

namespace EsenthelNet
{
	public enum class MeshBaseFlags {
		VTX_POS     =1<< 0, // vertex position
		VTX_NRM     =1<< 1, // vertex normal
		VTX_TNG     =1<< 2, // vertex tangent
		VTX_BIN     =1<< 3, // vertex binormal
		VTX_HLP     =1<<28, // vertex helper
		VTX_TEX0    =1<< 4, // vertex texture uv 0
		VTX_TEX1    =1<< 5, // vertex texture uv 1
		VTX_TEX2    =1<<31, // vertex texture uv 2
		VTX_COLOR   =1<<29, // vertex color
		VTX_MATERIAL=1<<27, // vertex material blend
		VTX_MATRIX  =1<< 6, // vertex matrix index
		VTX_BLEND   =1<< 7, // vertex matrix blend
		VTX_SIZE    =1<< 8, // vertex size
		VTX_FLAG    =1<<30, // vertex flag
		VTX_DUP     =1<< 9, // vertex duplicate

		EDGE_IND     =1<<10, // edge vertex index
		EDGE_ADJ_FACE=1<<11, // edge adjacent face
		EDGE_NRM     =1<<12, // edge normal
		EDGE_FLAG    =1<<13, // edge flag
		EDGE_ID      =1<<14, // edge id

		TRI_IND     =1<<15, // triangle vertex index
		TRI_ADJ_FACE=1<<16, // triangle adjacent face
		TRI_ADJ_EDGE=1<<17, // triangle adjacent edge
		TRI_NRM     =1<<18, // triangle normal
		TRI_FLAG    =1<<19, // triangle flag
		TRI_ID      =1<<20, // triangle id

		QUAD_IND     =1<<21, // quad vertex index
		QUAD_ADJ_FACE=1<<22, // quad adjacent face
		QUAD_ADJ_EDGE=1<<23, // quad adjacent edge
		QUAD_NRM     =1<<24, // quad normal
		QUAD_FLAG    =1<<25, // quad flag
		QUAD_ID      =1<<26, // quad id

		VTX_TEX_ALL=VTX_TEX0  |VTX_TEX1 |VTX_TEX2,
		VTX_SKIN   =VTX_MATRIX|VTX_BLEND         ,

		FACE_IND     =TRI_IND     |QUAD_IND     ,
		FACE_ADJ_FACE=TRI_ADJ_FACE|QUAD_ADJ_FACE,
		FACE_ADJ_EDGE=TRI_ADJ_EDGE|QUAD_ADJ_EDGE,
		FACE_NRM     =TRI_NRM     |QUAD_NRM     ,
		FACE_FLAG    =TRI_FLAG    |QUAD_FLAG    ,
		FACE_ID      =TRI_ID      |QUAD_ID      ,

		VTX_ALL= VTX_POS|VTX_NRM|VTX_TNG|VTX_BIN|VTX_HLP|VTX_TEX0|VTX_TEX1|VTX_TEX2|VTX_COLOR|VTX_MATERIAL|VTX_MATRIX|VTX_BLEND|VTX_SIZE|VTX_DUP|VTX_FLAG,
		EDGE_ALL=EDGE_IND|EDGE_ADJ_FACE|              EDGE_NRM|EDGE_FLAG|EDGE_ID,
		TRI_ALL= TRI_IND| TRI_ADJ_FACE| TRI_ADJ_EDGE| TRI_NRM| TRI_FLAG| TRI_ID,
		QUAD_ALL=QUAD_IND|QUAD_ADJ_FACE|QUAD_ADJ_EDGE|QUAD_NRM|QUAD_FLAG|QUAD_ID,
		FACE_ALL=FACE_IND|FACE_ADJ_FACE|FACE_ADJ_EDGE|FACE_NRM|FACE_FLAG|FACE_ID,
		ADJ_ALL=EDGE_ADJ_FACE|TRI_ADJ_FACE|TRI_ADJ_EDGE|QUAD_ADJ_FACE|QUAD_ADJ_EDGE,
		NRM_ALL= VTX_NRM|EDGE_NRM |TRI_NRM |QUAD_NRM ,
		FLAG_ALL=         EDGE_FLAG|TRI_FLAG|QUAD_FLAG,
		ID_ALL=         EDGE_ID  |TRI_ID  |QUAD_ID  ,

	};

	public ref class MeshBase {
	internal:
		MeshBase(EE::MeshBase* m) {
			//meshBase = new EE::MeshBase();
			meshBase = m;
		}

		EE::MeshBase* meshBase;
	public:
		MeshBase() {
			meshBase = new EE::MeshBase();
		}

		void Create(int vtxs, int edges, int tris, int quads, MeshBaseFlags flag) {
			meshBase->create(vtxs, edges, tris, quads, (UInt)flag);
		}

		void Create(EsenthelNet::Box^ box, MeshBaseFlags flag, int resolution) {
			meshBase->create(*box->box, (UInt)flag, resolution);
		}

		EsenthelNet::MeshBase^ Create(EsenthelNet::Ball^ ball, MeshBaseFlags flag, int resolution) {
			meshBase->create(*ball->ball, (UInt)flag, resolution);
			return this;
		}

		bool Is() {
			return meshBase->is();
		}


		void DrawAuto() {
			meshBase->drawAuto(NULL);
		}

	};
}